package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
import com.egao.orderB.biz.AreaBiz;
import com.egao.orderB.entity.Area;
import com.egao.orderB.service.AreaService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

//import com.egao.orderB.mapper.AreaMapper;
//import javax.transaction.Transactional;

/**
 * 区服务实现类
 * @author : Doman
 * @date : 2020-10-20 15:32:56
 * @version ：1.0
 */
@Service
public class AreaServiceImpl /*extends ServiceImpl<AreaMapper, Area> */implements AreaService {

	@Autowired
	private AreaBiz areaBiz;

    /**
    @Override
    public PageResult<Area> listPage(PageParam<Area> page) {
        List<Area> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Area> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Area area, User loginUser)  throws Exception{
        return areaBiz.list(page,area,loginUser);
    }

    @Override
    public JsonResult list(Area area, User loginUser) {
        return JsonResult.ok().setData(areaBiz.list(area,loginUser));
    }

    @Override
    public JsonResult getById(Area area) {
        return JsonResult.ok().setData(areaBiz.getById(area));
    }

    @Override
    public JsonResult save(Area area, User loginUser) {
        if (areaBiz.save(area, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Override
    public JsonResult update(Area area, User loginUser) {
        if (areaBiz.update(area, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Override
    public JsonResult remove(Area area, User loginUser) {
        if (areaBiz.remove(area, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
